package com.jzt.gateway.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 作者：lizw <br/>
 * 创建时间：2020/06/17 15:40 <br/>
 */
@ConfigurationProperties(prefix = "auth")
@Component
@Data
public class ServersConfig {
    /**
     * 是否启用账号注册重试任务
     */
    public boolean enableRegisterRetry = false;

    /**
     * AES加密 key
     */
    private String passwordSecretKey = "e3df4155e34a7c5ea5426b8efd148097";
    /**
     * AES加密 iv
     */
    private String passwordSecretIv = "253028364f3f459442fee5f40f0c71ec";
    /**
     * 安全相关基础配置
     */
    private final List<AuthConfig> servers = new ArrayList<>();

    public AuthConfig getAuthConfig(String routeId) {
        for (AuthConfig server : servers) {
            if (Objects.equals(server.getRouteId(), routeId)) {
                return server;
            }
        }
        return null;
    }
}
